home *** CD-ROM | disk | FTP | other *** search
- ' SEARCH.BAS
- ' This program reads data into three arrays and searches for a name.
- ' The maximum number of names that can be entered is 50; fewer
- ' can be entered by typing "END" for the salesperson name.
-
- OPTION BASE 1 ' set base of all arrays to 1
-
- DIM salesGroup$(50) ' dimension salesGroup$ string array
- DIM bikesSold%(50) ' dimension bikesSold% integer array
- DIM totalSales!(50) ' dimension totalSales! floating-point array
-
- CLS
-
- PRINT "Follow prompts to enter bike shop data. Type END to quit."
- PRINT
-
- count% = 1 ' initialize an array counter variable
-
- WHILE (salesGroup$(count%) <> "END") ' continue until name = "END"
- INPUT "Enter salesperson name: ", salesGroup$(count%)
-
- IF (salesGroup$(count%) <> "END") THEN
- INPUT " Bikes sold: ", bikesSold%(count%)
- INPUT " Total sales: $", totalSales!(count%)
- PRINT
- count% = count% + 1 ' increment the array counter
- END IF
- WEND
-
- PRINT ' prompt user for search string
- INPUT "What name would you like to search for? ", search$
- PRINT
-
- ' initialize tmp$, a formatting template for PRINT USING
- tmp$ = "\ \ ### $$####.##"
-
- ' compare each array element with search string until a match is
- ' found, then display the record and exit the loop; display
- ' message if search string is not found
-
- FOR i% = 1 TO count% - 1 ' count% - 1 is the last array element
- IF (salesGroup$(i%) = search$) THEN
- PRINT "Salesperson Bikes sold Total sales"
- PRINT "------------------------------------------"
- PRINT
- PRINT USING tmp$; salesGroup$(i%); bikesSold%(i%); totalSales!(i%)
- EXIT FOR ' this statement breaks out of a FOR loop
- END IF
- IF (i% = count% - 1) THEN PRINT "** Name not found **"
- NEXT i%
-
-